import Vue from 'vue'
import Vuex from 'vuex'
import user from '@/store/modules/user'
import getters from './getters'

Vue.use(Vuex)

const store = new Vuex.Store({
	modules: {
		user
	},
	state: {
		topIdList: [],
		nextId: '',
		tabbar: [],
		refresh: false,
		publishContentType: ''
	},
	mutations: {
		INIT_TABBAR(state, array) {
			state.tabbar = array
		},
		INIT_CHANGE(state, payload) {
			state.topIdList = payload;
		},
		NEXT_ID(state, payload) {
			for (var i = 0; i < state.topIdList.length; i++) {
				if (state.topIdList[i].id == payload) {
					state.nextId = state.topIdList[i + 1].id;
				}
			}
		},
		IS_REFRESH(state, refresh) {
			state.refresh = refresh
		},
		SET_PUBLISHCONTENTTYPE(state, publishContentType) {
			state.publishContentType = publishContentType
		}
	},
	getters
})

export default store